import re
import sys
def main():
  num_hidden_layers=5
  #input_size=440
  #ivec_size=25
  #hlayer_size=1024
  #hivec_size=100

  base_dnn="exp_pdnn/no_delta_dnn_fbank/nnet.finetune.tmp"
  str_ptr="exp_pdnn/100_Str_25_dnn_fbank_128/dnn.ptr"
  temp="exp_pdnn/warm_100_Str_25_dnn_fbank_128/init.tmp"
  
  base_dnn_file=open(base_dnn,'r')
  str_ptr_file=open(str_ptr,'r')
  temp=[]
  temp_file=open(temp,'w')
  
  temp_num=2*num_hidden_layers
  a=','.join(str(i) for i in xrange(1,temp_num) if i % 2 ==1)
  a=map(int,a.split(','))

  b=','.join(str(i) for i in xrange(1,temp_num+1) if i % 2 ==0)
  b=map(int,b.split(','))
  
  print 'processing the base dnn file '  
  for num_line,line in enumerate(base_dnn_file):
    #line = line.rstrip()
    #f (num_line ==0):
    # temp_file.write(line)
    
    if (num_line in a):
      line = line.replace('W','W1')
      temp.append(line)
      #temp_file.write(line)

    elif (num_line in b):
      line = line.replace('b','b1')
      temp.append(line)
      #temp_file.write(line)      
    #line = line.replace(',','')
    #line = line.replace(':','')
    #line = line.replace('"','')
    #line = line.replace('\\','')
    #line = line.replace('n',' ')
    #words=line.split()
    #print 'the line number is ',num_line
    #print words[-1]
    #if (num_line !=0) and (num_line !=13): 
    #  print words[0]
    #  print words[1]
    #  print words[2]
    #  print words[3]
    #print len(words)
  
  print len(temp)
  #sys.exit()
  print 'processing the str_ptr_file'
  for num_line,line in enumerate(str_ptr_file):
    line = line.rstrip()
    line = line.replace(',','')
    line = line.replace(':','')
    line = line.replace('"','')
    line = line.replace('\\','')
    line = line.replace('n',' ')
    words=line.split()
    print 'the line number is ',num_line
    print words[-1]
    if (num_line !=0) and (num_line !=28):
      print words[0]
      print words[1]
      print words[2]
      print words[3]
    print len(words)

    

if __name__=="__main__":
    main()

